//hook全部拦截器，延时启动


Java.perform(function () {
    var Builder = Java.use('okhttp3.OkHttpClient$Builder');
    Builder.addInterceptor.implementation = function (inter) {
        //console.log("实例化：");

        console.log(JSON.stringify(inter));
        //console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));
        return this.addInterceptor(inter);
    };

    // 导入相关的Java类
    var OkHttpClient = Java.use('okhttp3.OkHttpClient');


    OkHttpClient.newCall.overload('okhttp3.Request').implementation = function (request) {
        // 获取请求的URL
        var url = request.url().toString();

        // 如果请求的URL包含特定的关键字，则输出到控制台
        if (url.includes("/api/pub-med-math/point-question-chapter-detail")) {
            console.log("请求的URL：", url);

            // 发送请求并获取响应对象
            //var response = this.newCall(request);

            // 获取响应数据
            //var responseBody = response.body().string();
            //console.log("这是responseBody：", responseBody);
        }

        // 调用原始的newCall方法
        return this.newCall(request);
    }

});


/*
// 获取指定拦截器的数据
Java.perform(function() {
  // 获取要hook的类
  var OkHttpClientClass = Java.use("okhttp3.OkHttpClient");

  // hook Request方法
  OkHttpClientClass.newCall.overload('okhttp3.Request').implementation = function(request) {
    // 获取请求的URL
    var url = request.url().toString();
    var headers = request.headers().toString();

    var response = chain.proceed(request)
    var res = response.body().toString();
    //var requestBody = request.body();

    // 如果请求的URL包含特定的关键字，则输出到控制台
    if (url.includes("/api/pub-med-math/point-question-chapter-detail")) {
      console.log("请求的URL：", url);
      console.log("请求的Header：",headers);
      console.log("请求的res：",res);
      //console.log("请求的requestBody：",requestBody);
      console.log(Java.use("android.util.Log").getStackTraceString(Java.use("java.lang.Throwable").$new()));

    }

    // 调用原始的newCall方法
    return this.newCall(request);
  }

});
 */


//  frida -U -f com.uuedu.examant  -l 05_hook_All_interceptor.js
//  frida -UF -l 05_hook_All_interceptor.js